<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>	
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="${pageContext.request.contextPath }/statics/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
$(function(){
	list();
})
	 function list(){
		 $.ajax({
			"url":"${pageContext.request.contextPath}/petype?opr=findBreed&d="+new Date().getTime(),
			"type":"post",
			"dataType":"json",
			"success":function(data){
					var options = "<option value=\"0\">请选择</option>";
					for(var i=0; i<data.Breed.length;i++){
						options+="<option value=\""+data.Breed[i].vId+"\">"+data.Breed[i].vName+"</option>";
					}
					$(".petBreed").append(options);
				}
		}) 
	}
</script>
</head>
<body>
	<center>
		<h1 style="color:red">宠物管理系统</h1>
		
		<form action="${pageContext.request.contextPath}/pet?opr=select" method="post">
		品种 <select id="petBreed" name="petBreed" class="petBreed">
			
		</select>
		<input type="submit" name="sm" value="查询">
		<a href="${pageContext.request.contextPath}/pet?opr=toadd">添加</a>
		<table border="2">
			<tr>
				<th>宠物昵称</th>
				<th>出生日期</th>
				<th>性别</th>
			</tr>
			<c:forEach var="pet" items="${petList}">
			<tr class="pet">
				<td>${pet.petName}</td>
				<td><fmt:formatDate value="${pet.birthday}" pattern="yyyy-MM-dd"/></td>
				<c:if test="${pet.petSex==1}">
				<td>雄</td>
				</c:if>
				<c:if test="${pet.petSex==2}">
				<td>雌</td>
				</c:if>
			</tr>
			</c:forEach>
		</table>
		</form>
	</center>
</body>
</html>